import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate';

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user:{},
    // 在 state 中存储初始状态
    initialState: {
      user: {},
    }
  },
  getters: {
    count: (state) => state.count,
  },
  mutations: {
    setUser(state, user) {
      state.user = user;
    },
    resetState: (state) => {
      // 使用 state 中的 initialState
      Object.assign(state, state.initialState)
    },
  },
  actions: {
  },
  modules: {
  },
  plugins: [createPersistedState()],
})

